import { TERMINAL_TYPE } from '../common/enums'
import request from '../common/request'

interface ILoginForm {
  terminal: TERMINAL_TYPE
  userName: string
  password: string
}

export interface IRegisterForm {
  userName: string
  nickName: string
  password: string
  confirmPassword: string
}

const login = (data: ILoginForm) => {
  return request({
    url: '/login',
    method: 'POST',
    data
  })
}

const refreshToken = (data: any) => {
  return request({
    url: `/refreshToken`,
    method: 'PUT',
    data
  })
}

const register = (data: IRegisterForm) => {
  return request({
    url: `/register`,
    method: 'POST',
    data
  })
}

const modifyPwd = (data: any) => {
  return request({
    url: "/modifyPwd",
    method: "POST",
    data,
  })
}

export const loginApi = {
  login,
  refreshToken,
  register,
  modifyPwd
}